<template>
	<div class="box-all">
		<div class="card-buttom">
			<div class="card-box">
				<div class="card-box-bg">
					<div class='card'>
						<div class='mes'>恭喜您已领取花卡会员</div>
						<div class='bottm-box'>
							<div class='open-vip'>
								<div>激活花卡任务</div>
							</div>
							<div class='vip-x'>
								<span>邀请{{vipInfo.requestedRegisteredUserNum||5}}位好友注册花伴账号</span>
							</div>
						</div>
					</div>
				</div>
				<div class="shadow">
				</div>
				<div class='flex flex-item-between vip-info'>
					<div class='info-box'>
						<div class='img-box'>
							<img class='zk' src='https://zafgoos.oss-cn-shanghai.aliyuncs.com/hbplus/imgs-h5/vip_zk.png' />
						</div>
						<div class='info-tips'>全场成本价</div>
					</div>
					<div class='info-box'>
						<div class='img-box'>
							<img class='yf' src='https://zafgoos.oss-cn-shanghai.aliyuncs.com/hbplus/imgs-h5/vip_yf.png' />
						</div>
						<div class='info-tips'>全场免运费</div>
					</div>
					<div class='info-box'>
						<div class='img-box'>
							<img class='dx' src='https://zafgoos.oss-cn-shanghai.aliyuncs.com/hbplus/imgs/installment-icon.png' />
						</div>
						<div class='info-tips'>低息分期付</div>
					</div>
				</div>
				<div class="lnimt"></div>
				<div class='lookinterests flex flex-item-center' @click='onlookinterests'>
					<span>查看会员权益</span>
					<img src='https://zafgoos.oss-cn-shanghai.aliyuncs.com/hbplus/imgs/cor_right.png' />
				</div>
			</div>

			<div class="receivelist">
				<div class="receivelist-title flex flex-item-center">今日前十位领取会员用户</div>
				<div v-if="listData.length" class="receivelist-item flex flex-c">
					<div class="receivelist-item-box flex flex-item-between flex-item-v-center" v-for="item in listData">
						<span class="usernames">{{item.wxName||'...'}}</span>
						<div class="tu-wen flex flex-item-between flex-item-v-center">
							<img class="rc-img" :src="item.wxHeadImg" />
							<span>{{item.accountName}}</span>
						</div>
					</div>
				</div>
				<div v-else="" class="no-list flex flex-item-center">
					暂未有用户领取
				</div>
			</div>
		</div>
		<div class="invite" @click="share">立即邀请</div>
	</div>

</template>

<script>
	import http from '@/util/http'
	import Api from '@/util/api'
	import utils from '@/util/util'
	export default {
		data() {
			return {
				listData: [],
				vipInfo: {},
				singInfo: '',
				token:''
			}
		},
		created() {
			this.token = utils.getUserToken() || this.token;
			window.loginCallBack = (token) => {
				this.token = token;
				token && this.getUserInfo();;
			}
			this.getUserInfo();
		},
		methods: {
			onlookinterests() {
				var url = 'https://weixin.za-huaban.com/static/views/lagelVip.html'
				window.location.href = url;
			},
			getUserInfo() {
				http.post(Api.userGetVipUserInfo,{},{token:this.token},false)
					.then((d) => {
						if(d.code == 200) {
							if(d.data.expireTime) {
								var time = d.data.expireTime.replace(/-/g, '/');
								time = new Date(time);
								d.data.expireTime = utils.format(time, 'yyyy.MM.dd')
							}
							this.vipInfo = d.data;
							if(this.vipInfo.vip){
								this.toast('您已是会员,无需激活')
								setTimeout(()=>{
									window.history.go(-1);
								},2000)
							}
							if(d.data.checkVipIsAccpet) {
								this.GetInviterInfo();
								this.listGiftVipMemberHttp();
							}
						} else {
							this.toast(d.message)
						}
					})
					.catch((e) => {
						console.log(e)
					})
			},
			//查询会员用户列表
			listGiftVipMemberHttp() {
				http.post(Api.listGiftVipMember, {},{token:this.token},false).then((d) => {
					if(d.code == 200) {
						if(d.data.length <= 0) {
							this.listData = []
						} else {
							this.listData = d.data;
						}
					}
				}).catch((e) => {})
			},
			GetInviterInfo() {
				http.post(Api.getEntrySingInfo, {},{token:this.token},false).then((d) => {
					if(d.code == 200 && d.data != null) {
						this.singInfo = d.data
					} else {}
				}).catch((e) => {})
			},
			share() {
				var title = '帮我抢会员，就差你了!';
				var descr = '6565';
				var url1 = 'https://www.123.com';
				var image1 = 'https://zafgoos.oss-cn-shanghai.aliyuncs.com/hbplus/imgs-h5/ic_invitationto%20register.jpg';
				var pagePath = encodeURIComponent('/pages/find/find?channelCode=HUABAN&singInfo=' + this.singInfo);
				var userName = 'gh_951c6b3e8370'
				var str = 'huaban://socialShare?type=3&title=' + title + '&descr=' + descr + '&url=' + url1 + '&image=' + image1 + '&pagePath=' + pagePath + '&userName=' + userName
				window.location = str;
			}
		}
	}
</script>

<style lang="less" rel="stylesheet/less" scoped="scoped">
	@import '~@/assets/less/main.less';
	@import './css/index.less';
</style>